package com.hongkuncheng.cms.controller.interfaces;

import com.alibaba.fastjson.JSONObject;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Controller;
import com.hongkuncheng.cms.controller.BaseController;
import com.hongkuncheng.cms.model.Admin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 测试接口
 *
 * @author 洪坤成
 */
@Controller
@Transactional
@RequestMapping("interfaces/test")
@ResponseBody
public class IntestController extends BaseController {

    // 检测连接状态
    @RequestMapping
    public void index() {
        if (request.getParameter("callback") != null) {
            JSONObject object = new JSONObject();
            try {
                factorySession.load(Admin.class, 1);
                object.put("result", 1);
            } catch (Exception e) {
                object.put("result", 0);
            }
            print(request.getParameter("callback") + "(" + object + ")");
        } else {
            print("callback is null");
        }
    }

}
